package com.gmail.liulijuan.DB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

public class DealDao {
	public ArrayList getAllDeal() {
		ResultSet rs = null;
		Deal dl = null;
		ArrayList dealal = new ArrayList();
		try {
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			String url = "jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=mydb.mdb";
			Connection conn = DriverManager.getConnection(url, "", "");
			Statement stmt = conn.createStatement();
			rs = stmt.executeQuery("SELECT * FROM Employee");

			while (rs.next()) {
				dl = new Deal();
				dl.setID(rs.getInt("ID"));
				dl.setCustomName(rs.getString("CustomName"));
				dl.setEmployeeName(rs.getString("EmployName"));
				dl.setService1(rs.getString("Service1"));
				dl.setService2(rs.getString("Service2"));
				dl.setAssistant(rs.getString("Assistant"));
				dl.setPrice(rs.getFloat("Price"));
				dl.setComments(rs.getString("Comments"));
				
				dealal.add(dl);
			}

			rs.close();

			stmt.close();
			conn.close();

		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return dealal;
	}

}
